# the image base on stretch has higher speed on executing provision script then alpine
FROM openresty/openresty:1.15.8.3-stretch

LABEL maintainer="Han <yinhu@qq.com>"

# Define build args

# The CloudSS releasing version, usually given at building image
ARG CloudSS_VERSION
ARG CloudSS_GATEWAY_HOME="/CloudSS/gateway"

LABEL CloudSS.service "openresty"
LABEL CloudSS.version ${CloudSS_VERSION}

ENV CONTAINERIZED="true" \
    CloudSS_GATEWAY_HOME="$CloudSS_GATEWAY_HOME" \
    CloudSS_GATEWAY_LISTEN_PORT="80" \
    CloudSS_GATEWAY_SSL_LISTEN_PORT="443" \
    CloudSS_GATEWAY_LOG_LEVEL="notice"


WORKDIR $CloudSS_GATEWAY_HOME

# Redirect standard output and error stream
RUN mkdir -p logs && \
    ln -s /dev/stdout ${CloudSS_GATEWAY_HOME}/logs/access.log && \
    ln -s /dev/stderr ${CloudSS_GATEWAY_HOME}/logs/error.log


## Add files
COPY lualib/cjson.so /usr/local/openresty/lualib/
COPY lualib/ lualib/
COPY startup.sh .
COPY conf/ conf/


# Run Command
CMD ./startup.sh
